package cn.com.huzo.service.trade.impl;

import cn.com.huzo.model.entities.trade.ProductionInstructionLinesPictureEntity;
import huzofw.common.util.file.DeleteDirectoryAndFile;
import huzofw.service.impl.GenericManagerImpl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.com.huzo.repository.trade.ProductionInstructionLinesPictureRepository;
import cn.com.huzo.service.trade.ProductionInstructionLinesPictureManager;

/**
 * 生产指示书图片管理服务对象类实现。
 *
 * @author 吴旭
 */
@Service("ProductionInstructionLinesPictureManager")
public class ProductionInstructionLinesPictureManagerImpl extends GenericManagerImpl<ProductionInstructionLinesPictureEntity, String>
        implements ProductionInstructionLinesPictureManager {

    @Resource(name = "ProductionInstructionLinesPictureRepository")
    private ProductionInstructionLinesPictureRepository _dao_lines_picture;

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    public List<ProductionInstructionLinesPictureEntity> fetchAll(Long materialKey) throws Exception {
        return _dao_lines_picture.fetchAll(materialKey);
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    public String insert(ProductionInstructionLinesPictureEntity instance) throws Exception {
        return _dao_lines_picture.insert(instance);
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Override
    public Integer delete(ProductionInstructionLinesPictureEntity instance) throws Exception {
        DeleteDirectoryAndFile.deleteFile(instance.getImageFileDir() + "/" + instance.getImageFileName());
        return _dao_lines_picture.delete(instance.getLinesId());
    }
}
